﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using AI;
using Assets.Scripts.GtsScripts;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;

// Token: 0x0200037E RID: 894
public class ObjectManager : NetworkBehaviour
{
	// Token: 0x1400000B RID: 11
	// (add) Token: 0x0600174D RID: 5965 RVA: 0x00094C80 File Offset: 0x00092E80
	// (remove) Token: 0x0600174E RID: 5966 RVA: 0x00094CB8 File Offset: 0x00092EB8
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	public event ObjectManager.ObjectEvent OnGiantessAdd;

	// Token: 0x1400000C RID: 12
	// (add) Token: 0x0600174F RID: 5967 RVA: 0x00094CF0 File Offset: 0x00092EF0
	// (remove) Token: 0x06001750 RID: 5968 RVA: 0x00094D28 File Offset: 0x00092F28
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	public event ObjectManager.ObjectEvent OnGiantessRemove;

	// Token: 0x06001751 RID: 5969 RVA: 0x00094D60 File Offset: 0x00092F60
	private void Awake()
	{
		ObjectManager.Instance = this;
		this.playerCamera = Camera.main.GetComponent<PlayerCamera>();
		this.spawnPoint = this.playerCamera.transform.position - Vector3.up * PlayerCamera.defaultHeight;
		ObjectManager.modelManager = IOManager.Instance;
		this.maleMicroModels = this.LoadMicroList(ObjectManager.MicroGender.Male);
		this.femaleMicroModels = this.LoadMicroList(ObjectManager.MicroGender.Female);
		ObjectManager.cachedObjects = new Dictionary<string, GameObject>();
		this.vehicles = new List<VehicleEnterExit>();
		this.giantessList = new Dictionary<int, Giantess>();
		this.objectList = new Dictionary<int, EntityBase>();
		ObjectManager.maleMicroAssetId = NetworkHash128.Parse("223234342");
		ObjectManager.femaleMicroAssetId = NetworkHash128.Parse("675756754");
		ClientScene.RegisterSpawnHandler(ObjectManager.maleMicroAssetId, new UnityEngine.Networking.SpawnDelegate(this.SpawnMaleMicro), new UnityEngine.Networking.UnSpawnDelegate(this.UnSpawnMicro));
		ClientScene.RegisterSpawnHandler(ObjectManager.femaleMicroAssetId, new UnityEngine.Networking.SpawnDelegate(this.SpawnFemaleMicro), new UnityEngine.Networking.UnSpawnDelegate(this.UnSpawnMicro));
		foreach (KeyValuePair<NetworkHash128, string> keyValuePair in ObjectManager.modelManager.hashPlayer)
		{
			ClientScene.RegisterSpawnHandler(keyValuePair.Key, new UnityEngine.Networking.SpawnDelegate(this.SpawnPlayer), new UnityEngine.Networking.UnSpawnDelegate(this.UnSpawnPlayer));
		}
		foreach (KeyValuePair<NetworkHash128, string> keyValuePair2 in ObjectManager.modelManager.hashObjects)
		{
			ClientScene.RegisterSpawnHandler(keyValuePair2.Key, new UnityEngine.Networking.SpawnDelegate(this.SpawnObject), new UnityEngine.Networking.UnSpawnDelegate(this.UnSpawnObject));
		}
		foreach (KeyValuePair<NetworkHash128, string> keyValuePair3 in ObjectManager.modelManager.hashGiantess)
		{
			ClientScene.RegisterSpawnHandler(keyValuePair3.Key, new UnityEngine.Networking.SpawnDelegate(this.SpawnGiantess), new UnityEngine.Networking.UnSpawnDelegate(this.UnSpawnGiantess));
		}
		foreach (KeyValuePair<NetworkHash128, string> keyValuePair4 in ObjectManager.modelManager.hashPlayableGiantess)
		{
			ClientScene.RegisterSpawnHandler(keyValuePair4.Key, new UnityEngine.Networking.SpawnDelegate(this.SpawnPlayableGiantess), new UnityEngine.Networking.UnSpawnDelegate(this.UnSpawnGiantess));
		}
		this.microManager = new MicroManager();
		this.gtsManager = new GiantessManager();
	}

	// Token: 0x06001752 RID: 5970 RVA: 0x0009502C File Offset: 0x0009322C
	private void Update()
	{
		this.microManager.Update();
	}

	// Token: 0x06001753 RID: 5971 RVA: 0x00095039 File Offset: 0x00093239
	public void OnObjectSpawned(EntityBase entity)
	{
		if (entity.isHumanoid)
		{
			return;
		}
		this.objectList[entity.id] = entity;
		SavedScenesManager.Instance.OnObjectLoaded(entity);
	}

	// Token: 0x06001754 RID: 5972 RVA: 0x00095064 File Offset: 0x00093264
	public void OnGiantessSpawned(Giantess giantess)
	{
		this.giantessList[giantess.id] = giantess;
		SavedScenesManager.Instance.OnGiantessLoaded(giantess);
		if (this.OnGiantessAdd != null)
		{
			this.OnGiantessAdd(giantess.id);
		}
	}

	// Token: 0x06001755 RID: 5973 RVA: 0x000950A0 File Offset: 0x000932A0
	public void RemoveNullObjectsInList()
	{
		List<int> list = new List<int>();
		foreach (KeyValuePair<int, EntityBase> keyValuePair in this.objectList)
		{
			if (keyValuePair.Value == null)
			{
				list.Add(keyValuePair.Key);
			}
		}
		foreach (int key in list)
		{
			this.objectList.Remove(key);
		}
	}

	// Token: 0x06001756 RID: 5974 RVA: 0x00095168 File Offset: 0x00093368
	public static GameObject LoadPlayer(string name)
	{
		GameObject gameObject = ObjectManager.modelManager.LoadPlayerModel(name);
		if (gameObject == null)
		{
			UnityEngine.Debug.Log("Player " + name + " not found, instancing random skin");
			gameObject = ObjectManager.modelManager.LoadRandomPlayerModel();
		}
		gameObject.AddComponent<Player>();
		gameObject.AddComponent<Destructor>();
		gameObject.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
		if (GameController.IsMultiplayer())
		{
			NetworkTransform networkTransform = gameObject.AddComponent<NetworkTransform>();
			networkTransform.sendInterval = 0.02f;
			networkTransform.transformSyncMode = NetworkTransform.TransformSyncMode.SyncTransform;
			Animator component = gameObject.GetComponent<Animator>();
			NetworkAnimator networkAnimator = gameObject.AddComponent<NetworkAnimator>();
			networkAnimator.animator = component;
			int num = 10;
			for (int i = 0; i < num; i++)
			{
				networkAnimator.SetParameterAutoSend(i, true);
			}
		}
		return gameObject;
	}

	// Token: 0x06001757 RID: 5975 RVA: 0x00095224 File Offset: 0x00093424
	public GameObject SpawnPlayer(Vector3 position, NetworkHash128 assetId)
	{
		UnityEngine.Debug.Log("Spawning Player " + assetId);
		string name;
		if (!ObjectManager.modelManager.hashPlayer.TryGetValue(assetId, out name))
		{
			UnityEngine.Debug.Log("The player doesn't have the model trying to spawn");
		}
		return UnityEngine.Object.Instantiate<GameObject>(ObjectManager.LoadPlayer(name), position, Quaternion.identity);
	}

	// Token: 0x06001758 RID: 5976 RVA: 0x00095278 File Offset: 0x00093478
	public void UnSpawnPlayer(GameObject spawned)
	{
		UnityEngine.Object.Destroy(spawned);
	}

	// Token: 0x06001759 RID: 5977 RVA: 0x00095280 File Offset: 0x00093480
	public GameObject SpawnObject(Vector3 position, NetworkHash128 assetId)
	{
		UnityEngine.Debug.Log("Spawning " + assetId.ToString());
		string id;
		if (!ObjectManager.modelManager.hashObjects.TryGetValue(assetId, out id))
		{
			UnityEngine.Debug.Log("Spawned and object not avaivable for this user.");
			return null;
		}
		return UnityEngine.Object.Instantiate<GameObject>(ObjectManager.LoadObject(id), position, Quaternion.identity);
	}

	// Token: 0x0600175A RID: 5978 RVA: 0x000952DD File Offset: 0x000934DD
	public void UnSpawnObject(GameObject spawned)
	{
		spawned.GetComponent<EntityBase>()._DestroyObject(true);
	}

	// Token: 0x0600175B RID: 5979 RVA: 0x000952EC File Offset: 0x000934EC
	private static GameObject LoadGiantess(string id)
	{
		GameObject gameObject;
		if (!ObjectManager.cachedObjects.TryGetValue(id, out gameObject))
		{
			gameObject = ObjectManager.modelManager.LoadGiantessModel(id);
			if (gameObject == null)
			{
				UnityEngine.Debug.LogError(id + " not found.");
				return null;
			}
			MeshCollider[] componentsInChildren = gameObject.GetComponentsInChildren<MeshCollider>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].sharedMesh = null;
			}
			gameObject.AddComponent<GiantessIK>();
			gameObject.AddComponent<Giantess>();
			gameObject.AddComponent<GiantessControl>().enabled = false;
			gameObject.AddComponent<ResizeCharacter>().enabled = false;
			gameObject.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
			NetworkTransform networkTransform = gameObject.AddComponent<NetworkTransform>();
			networkTransform.sendInterval = 0.01f;
			networkTransform.transformSyncMode = NetworkTransform.TransformSyncMode.SyncTransform;
			NetworkAnimator networkAnimator = gameObject.AddComponent<NetworkAnimator>();
			networkAnimator.animator = gameObject.GetComponent<Animator>();
			int num = 3;
			for (int j = 0; j < num; j++)
			{
				networkAnimator.SetParameterAutoSend(j, true);
			}
			ObjectManager.cachedObjects.Add(id, gameObject);
		}
		return gameObject;
	}

	// Token: 0x0600175C RID: 5980 RVA: 0x000953EC File Offset: 0x000935EC
	public GameObject InstantiateGiantess(bool useAlternateShaders, bool useAlternateTangents, string id, Vector3 position, Quaternion rotation, float scale = 1f)
	{
		GameObject gameObject = ObjectManager.LoadGiantess(id);
		if (gameObject == null)
		{
			return null;
		}
		GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject, position, rotation);
		Giantess component = gameObject2.GetComponent<Giantess>();
		component.ChangeScale(scale);
		component.useAltShaders = useAlternateShaders;
		component.useAltTangents = useAlternateTangents;
		return gameObject2;
	}

	// Token: 0x0600175D RID: 5981 RVA: 0x00095438 File Offset: 0x00093638
	public GameObject InstantiatePlayableGiantess(string id, Vector3 position, float scale, bool useAlternateShaders, bool useAlternateTangents)
	{
		GameObject gameObject = this.InstantiateGiantess(useAlternateShaders, useAlternateTangents, id, position, Quaternion.identity, scale);
		gameObject = this.MakeGTSPlayable(gameObject);
		Player playerInstance = GameController.playerInstance;
		playerInstance.myTransform.SetParent(gameObject.transform);
		playerInstance.myTransform.position = gameObject.transform.position;
		playerInstance.myTransform.rotation = gameObject.transform.rotation;
		GameController.playerInstance.SetActive(false);
		if (PlayerCamera.instance.entity != null && PlayerCamera.instance.entity.isGiantess)
		{
			PlayerCamera.instance.entity.DestroyObject(true);
		}
		return gameObject;
	}

	// Token: 0x0600175E RID: 5982 RVA: 0x000954E8 File Offset: 0x000936E8
	public GameObject MakeGTSPlayable(GameObject giantess)
	{
		giantess.GetComponent<GiantessControl>().enabled = true;
		ResizeCharacter component = giantess.GetComponent<ResizeCharacter>();
		component.enabled = true;
		component.sizeChangeRate = 0.2f;
		Giantess component2 = giantess.GetComponent<Giantess>();
		component2.ai.DisableAI();
		return giantess;
	}

	// Token: 0x0600175F RID: 5983 RVA: 0x00095530 File Offset: 0x00093730
	public GameObject SpawnGiantess(Vector3 position, NetworkHash128 assetId)
	{
		UnityEngine.Debug.Log("Spawning GTS " + assetId.ToString());
		string id;
		if (!ObjectManager.modelManager.hashGiantess.TryGetValue(assetId, out id))
		{
			UnityEngine.Debug.Log("Spawned giantess not avaivable for this user.");
			return null;
		}
		return UnityEngine.Object.Instantiate<GameObject>(ObjectManager.LoadGiantess(id), position, Quaternion.identity);
	}

	// Token: 0x06001760 RID: 5984 RVA: 0x00095590 File Offset: 0x00093790
	public GameObject SpawnPlayableGiantess(Vector3 position, NetworkHash128 assetId)
	{
		UnityEngine.Debug.Log("Spawning GTS " + assetId.ToString());
		string id;
		if (!ObjectManager.modelManager.hashPlayableGiantess.TryGetValue(assetId, out id))
		{
			UnityEngine.Debug.Log("Spawned giantess not avaivable for this user.");
			return null;
		}
		GameObject giantess = UnityEngine.Object.Instantiate<GameObject>(ObjectManager.LoadGiantess(id), position, Quaternion.identity);
		return this.MakeGTSPlayable(giantess);
	}

	// Token: 0x06001761 RID: 5985 RVA: 0x000955F5 File Offset: 0x000937F5
	public void UnSpawnGiantess(GameObject spawned)
	{
		this.gtsManager.RemoveGiantess(spawned.GetComponent<Giantess>().id);
		spawned.GetComponent<Giantess>()._DestroyObject(true);
	}

	// Token: 0x06001762 RID: 5986 RVA: 0x0009561C File Offset: 0x0009381C
	private List<MicroNPC> LoadMicroList(ObjectManager.MicroGender gender)
	{
		List<GameObject> list;
		if (gender == ObjectManager.MicroGender.Male)
		{
			list = ObjectManager.modelManager.GetMaleMicroModels();
		}
		else
		{
			list = ObjectManager.modelManager.GetFemaleMicroModels();
		}
		if (list != null)
		{
			List<MicroNPC> list2 = new List<MicroNPC>();
			for (int i = 0; i < list.Count; i++)
			{
				GameObject gameObject = list[i];
				gameObject.layer = Layers.microLayer;
				Animator component = gameObject.GetComponent<Animator>();
				AnimationManager.SetAnimatorController(component, ObjectManager.modelManager.microAnimatorController);
				SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
				foreach (SkinnedMeshRenderer skinnedMeshRenderer in componentsInChildren)
				{
					skinnedMeshRenderer.quality = SkinQuality.Bone1;
					skinnedMeshRenderer.lightProbeUsage = LightProbeUsage.Off;
					skinnedMeshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
					skinnedMeshRenderer.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion;
					skinnedMeshRenderer.skinnedMotionVectors = false;
				}
				CapsuleCollider capsuleCollider = gameObject.AddComponent<CapsuleCollider>();
				capsuleCollider.center = new Vector3(0f, 0.8f, 0f);
				capsuleCollider.radius = 0.3f;
				capsuleCollider.height = 1.6f;
				MicroNPC microNPC;
				if (this.getRecursiveChildCount(gameObject.transform) < 15)
				{
					microNPC = gameObject.AddComponent<EfficientMicroNPC>();
				}
				else
				{
					microNPC = gameObject.AddComponent<AnimatedMicroNPC>();
				}
				microNPC.rbody = gameObject.AddComponent<Rigidbody>();
				microNPC.rbody.freezeRotation = true;
				microNPC.rbody.mass = 0.5f;
				list2.Add(microNPC);
			}
			return list2;
		}
		return null;
	}

	// Token: 0x06001763 RID: 5987 RVA: 0x00095788 File Offset: 0x00093988
	private int getRecursiveChildCount(Transform root)
	{
		int num = 1;
		IEnumerator enumerator = root.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform root2 = (Transform)obj;
				num += this.getRecursiveChildCount(root2);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		return num;
	}

	// Token: 0x06001764 RID: 5988 RVA: 0x000957F0 File Offset: 0x000939F0
	public GameObject InstantiateMicro(MicroNPC tinyAi, Vector3 position, Quaternion rotation, float scale = 1f)
	{
		Micro micro = UnityEngine.Object.Instantiate<Micro>(tinyAi, position, rotation);
		if (micro == null)
		{
			return null;
		}
		this.microSpawnScale = scale;
		return micro.gameObject;
	}

	// Token: 0x06001765 RID: 5989 RVA: 0x00095824 File Offset: 0x00093A24
	public GameObject SpawnMaleMicro(Vector3 position, NetworkHash128 assetId)
	{
		Micro model = this.maleMicroModels[UnityEngine.Random.Range(0, this.maleMicroModels.Count)];
		return this.SpawnMicro(position, model);
	}

	// Token: 0x06001766 RID: 5990 RVA: 0x00095858 File Offset: 0x00093A58
	public GameObject SpawnFemaleMicro(Vector3 position, NetworkHash128 assetId)
	{
		Micro model = this.femaleMicroModels[UnityEngine.Random.Range(0, this.femaleMicroModels.Count)];
		return this.SpawnMicro(position, model);
	}

	// Token: 0x06001767 RID: 5991 RVA: 0x0009588C File Offset: 0x00093A8C
	public GameObject SpawnMicro(Vector3 position, Micro model)
	{
		Micro micro = UnityEngine.Object.Instantiate<Micro>(model, position, Quaternion.identity);
		micro.gameObject.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
		this.microManager.AddMicro(micro);
		return micro.gameObject;
	}

	// Token: 0x06001768 RID: 5992 RVA: 0x000958C9 File Offset: 0x00093AC9
	public void UnSpawnMicro(GameObject spawned)
	{
		this.microManager.RemoveMicro(spawned.GetComponent<Micro>().id);
		UnityEngine.Object.Destroy(spawned);
	}

	// Token: 0x06001769 RID: 5993 RVA: 0x000958E7 File Offset: 0x00093AE7
	public void OnMicroNPCSpawned(MicroNPC micro)
	{
		micro.ChangeScale(this.microSpawnScale);
	}

	// Token: 0x0600176A RID: 5994 RVA: 0x000958F5 File Offset: 0x00093AF5
	public GameObject MakeMicroPlayable(GameObject micro)
	{
		UnityEngine.Object.Destroy(micro.GetComponent<AnimatedMicroNPC>());
		base.StartCoroutine(this.AddMicroControl(micro));
		return micro;
	}

	// Token: 0x0600176B RID: 5995 RVA: 0x00095914 File Offset: 0x00093B14
	private IEnumerator AddMicroControl(GameObject micro)
	{
		yield return new WaitForSeconds(0.01f);
		micro.AddComponent<MicroControl>();
		yield return null;
		yield break;
	}

	// Token: 0x0600176C RID: 5996 RVA: 0x00095930 File Offset: 0x00093B30
	public void PlayAsEntity(EntityBase entity)
	{
		EntityBase entity2 = Camera.main.GetComponent<PlayerCamera>().entity;
		if (entity.isGiantess)
		{
			Player player = null;
			if (entity2.isGiantess)
			{
				Player component;
				if (entity2.transform.Find("Player Character").GetComponent<Player>() != null)
				{
					component = entity2.transform.Find("Player Character").GetComponent<Player>();
				}
				else
				{
					component = entity2.transform.Find("Player Character").GetComponent<MicroControl>();
				}
				player = component;
			}
			else if (entity2.isMicro)
			{
				GameObject gameObject = entity2.gameObject;
				if (gameObject.GetComponent<MicroControl>() != null)
				{
					player = UnityEngine.Object.Instantiate<MicroControl>(gameObject.GetComponent<MicroControl>());
				}
				else
				{
					player = UnityEngine.Object.Instantiate<Player>(gameObject.GetComponent<Player>());
				}
				player.name = gameObject.name;
			}
			this.PlayAsGts(entity, player);
		}
		else if (entity.isMicro)
		{
			this.MakeMicroPlayable(entity.gameObject);
		}
		if (entity2.isGiantess)
		{
			if (!entity.isGiantess)
			{
				Player component2;
				if (entity2.transform.Find("Player Character").GetComponent<MicroControl>() != null)
				{
					component2 = entity2.transform.Find("Player Character").GetComponent<MicroControl>();
				}
				else
				{
					component2 = entity2.transform.Find("Player Character").GetComponent<Player>();
				}
				component2.gameObject.SetActive(false);
				base.StartCoroutine(this.DestroyPlayer(component2.gameObject));
			}
			entity2.GetComponent<GiantessControl>().enabled = false;
			ResizeCharacter component3 = entity2.GetComponent<ResizeCharacter>();
			component3.enabled = false;
			entity2.ik.EnableLookAt();
		}
		else if (entity2.isMicro)
		{
			GameObject gameObject2 = entity2.gameObject;
			gameObject2.layer = Layers.microLayer;
			if (gameObject2.GetComponent<MicroControl>() != null)
			{
				UnityEngine.Object.Destroy(gameObject2.GetComponent<MicroControl>());
				AnimatedMicroNPC animatedMicroNPC = gameObject2.AddComponent<AnimatedMicroNPC>();
				animatedMicroNPC.rbody = animatedMicroNPC.gameObject.GetComponent<Rigidbody>();
				UnityEngine.Object.Destroy(animatedMicroNPC.gameObject.GetComponent<AnimationManager>());
				animatedMicroNPC.animationManager = animatedMicroNPC.gameObject.AddComponent<AnimationManager>();
				animatedMicroNPC.movement.anim = animatedMicroNPC.animationManager;
				animatedMicroNPC.actionManager.SetAgent(animatedMicroNPC);
				animatedMicroNPC.ai = animatedMicroNPC.gameObject.AddComponent<AIController>();
				animatedMicroNPC.ai.Initialize(animatedMicroNPC);
				entity2.GetComponent<ResizeCharacter>().enabled = false;
				if (GlobalPreferences.MicroAI.value)
				{
					animatedMicroNPC.ai.EnableAI();
				}
			}
			else
			{
				gameObject2.GetComponent<Player>().isDead = true;
				gameObject2.SetActive(false);
				base.StartCoroutine(this.DestroyPlayer(gameObject2));
			}
		}
	}

	// Token: 0x0600176D RID: 5997 RVA: 0x00095BF4 File Offset: 0x00093DF4
	private void PlayAsGts(EntityBase entity, Player player)
	{
		if (entity.transform.Find("Player Character") != null)
		{
			UnityEngine.Object.Destroy(entity.transform.Find("Player Character").gameObject);
		}
		float scale = entity.Scale;
		entity.gameObject.GetComponent<NetworkIdentity>().RemoveClientAuthority(ClientPlayer.Instance.connectionToClient);
		this.MakeGTSPlayable(entity.gameObject);
		entity.gameObject.GetComponent<GiantessControl>().SetPlayer(player);
		entity.gameObject.GetComponent<NetworkIdentity>().AssignClientAuthority(ClientPlayer.Instance.connectionToClient);
		entity.transform.rotation = new Quaternion(0f, entity.transform.rotation.y, 0f, entity.transform.rotation.w);
		player.myTransform.position = entity.transform.position;
		player.myTransform.rotation = entity.transform.rotation;
		player.myTransform.SetParent(entity.transform);
		if (entity.isGiantess)
		{
			player.enabled = false;
			player.SetActive(false);
		}
		GameController.Instance.SetPlayerInstance(player);
		base.StartCoroutine(this.RestoreScale(entity, scale));
	}

	// Token: 0x0600176E RID: 5998 RVA: 0x00095D44 File Offset: 0x00093F44
	private IEnumerator RestoreScale(EntityBase entity, float scale)
	{
		yield return null;
		entity.ChangeScale(scale);
		yield break;
	}

	// Token: 0x0600176F RID: 5999 RVA: 0x00095D68 File Offset: 0x00093F68
	private IEnumerator DestroyPlayer(GameObject player)
	{
		yield return new WaitForSeconds(0.02f);
		UnityEngine.Object.Destroy(player);
		yield break;
	}

	// Token: 0x06001770 RID: 6000 RVA: 0x00095D84 File Offset: 0x00093F84
	private static GameObject LoadObject(string id)
	{
		GameObject gameObject;
		if (!ObjectManager.cachedObjects.TryGetValue(id, out gameObject))
		{
			gameObject = ObjectManager.modelManager.LoadObject(id);
			if (gameObject == null)
			{
				UnityEngine.Debug.LogError(id + " not found.");
				return null;
			}
			gameObject.layer = Layers.objectLayer;
			if (gameObject.GetComponent<EntityBase>() == null)
			{
				gameObject.AddComponent<EntityBase>();
			}
			gameObject.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
			ObjectManager.cachedObjects.Add(id, gameObject);
		}
		return gameObject;
	}

	// Token: 0x06001771 RID: 6001 RVA: 0x00095E0C File Offset: 0x0009400C
	public GameObject InstantiateObject(string name, Vector3 position, Quaternion rotation, float scale = 1f)
	{
		GameObject gameObject = ObjectManager.LoadObject(name);
		if (gameObject == null)
		{
			return null;
		}
		GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject, position, rotation);
		gameObject2.transform.localScale = Vector3.one * scale;
		return gameObject2;
	}

	// Token: 0x06001772 RID: 6002 RVA: 0x00095E50 File Offset: 0x00094050
	public void OnObjectAuthoritySpawned(EntityBase entity)
	{
		VehicleEnterExit component = entity.GetComponent<VehicleEnterExit>();
		if (component)
		{
			this.vehicles.Add(component);
		}
	}

	// Token: 0x06001773 RID: 6003 RVA: 0x00095E7C File Offset: 0x0009407C
	public static NetworkHash128 GetHash(string name)
	{
		if (name == null)
		{
			UnityEngine.Debug.LogError("GetHash: Empty String");
		}
		string text = name.GetHashCode().ToString("x");
		return NetworkHash128.Parse(text);
	}

	// Token: 0x06001774 RID: 6004 RVA: 0x00095EB4 File Offset: 0x000940B4
	public void UpdateAllSpeeds()
	{
		foreach (KeyValuePair<int, Giantess> keyValuePair in this.giantessList)
		{
			if (keyValuePair.Value != null)
			{
				keyValuePair.Value.movement.anim.UpdateAnimationSpeed();
			}
			else
			{
				UnityEngine.Debug.LogError("Null giantess in list");
			}
		}
	}

	// Token: 0x06001775 RID: 6005 RVA: 0x00095F40 File Offset: 0x00094140
	public void RemoveGiantess(int id)
	{
		if (!this.giantessList.ContainsKey(id))
		{
			return;
		}
		this.giantessList.Remove(id);
		if (this.OnGiantessRemove != null)
		{
			this.OnGiantessRemove(id);
		}
	}

	// Token: 0x06001776 RID: 6006 RVA: 0x00002973 File Offset: 0x00000B73
	private void UNetVersion()
	{
	}

	// Token: 0x06001777 RID: 6007 RVA: 0x00095F78 File Offset: 0x00094178
	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool result;
		return result;
	}

	// Token: 0x06001778 RID: 6008 RVA: 0x00002973 File Offset: 0x00000B73
	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
	}

	// Token: 0x040019BD RID: 6589
	public static ObjectManager Instance;

	// Token: 0x040019BE RID: 6590
	private PlayerCamera playerCamera;

	// Token: 0x040019BF RID: 6591
	private MicroManager microManager;

	// Token: 0x040019C0 RID: 6592
	private GiantessManager gtsManager;

	// Token: 0x040019C1 RID: 6593
	public Vector3 spawnPoint;

	// Token: 0x040019C2 RID: 6594
	public List<MicroNPC> maleMicroModels;

	// Token: 0x040019C3 RID: 6595
	public List<MicroNPC> femaleMicroModels;

	// Token: 0x040019C4 RID: 6596
	private static IOManager modelManager;

	// Token: 0x040019C5 RID: 6597
	private static Dictionary<string, GameObject> cachedObjects;

	// Token: 0x040019C6 RID: 6598
	public List<VehicleEnterExit> vehicles;

	// Token: 0x040019C7 RID: 6599
	public Dictionary<int, EntityBase> objectList;

	// Token: 0x040019C8 RID: 6600
	public Dictionary<int, Giantess> giantessList;

	// Token: 0x040019CB RID: 6603
	public static NetworkHash128 maleMicroAssetId;

	// Token: 0x040019CC RID: 6604
	public static NetworkHash128 femaleMicroAssetId;

	// Token: 0x040019CD RID: 6605
	private float microSpawnScale = 1f;

	// Token: 0x0200037F RID: 895
	// (Invoke) Token: 0x0600177A RID: 6010
	public delegate void ObjectEvent(int id);

	// Token: 0x02000380 RID: 896
	private enum MicroGender
	{
		// Token: 0x040019CF RID: 6607
		Male,
		// Token: 0x040019D0 RID: 6608
		Female
	}

	// Token: 0x02000381 RID: 897
	// (Invoke) Token: 0x0600177E RID: 6014
	public delegate GameObject SpawnDelegate(Vector3 position, NetworkHash128 assetId);

	// Token: 0x02000382 RID: 898
	// (Invoke) Token: 0x06001782 RID: 6018
	public delegate void UnSpawnDelegate(GameObject spawned);
}
